<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
		<style>
			.box1{
				width: 18.75rem;
				height: 18.75rem;
				background-color: #0000FF;
			}
			.box2{
				width: 12.5rem;
				height: 12.5rem;
				background-color: #FF0000;
			}
			.box3{
				width: 6.25rem;
				height: 6.25rem;
				background-color: aqua;
			}
		</style>
	</head>
	<body>
		<!--
		stop：阻止冒泡事件
		-->
		<div id="test">
			<p>{{ msg }}</p>
			<!--
				不加上.stop会存在冒泡事件，即触发内层事件，会同时触发上层的事件
			-->
			<div class="box1" @click="clickbox1">
				<div class="box2" @click.stop="clickbox2">
					<div class="box3" @click.stop="clickbox3">
						
					</div>
				</div>
			</div>
		</div>
		
		<!--
		prevent：阻止默认事件
		-->
		<div id="test1">
			<p>{{ msg }}</p>
			<!--
				不加上.stop会存在冒泡事件，即触发内层事件，会同时触发上层的事件
			-->
			<a href="http://www.baidu.com" @click.prevent="clickhref">百度一下</a>
		</div>
		
		<!--
		capture：
		-->
		<div id="test2">
			<p>{{ msg }}</p>
			<!--
				不加上.stop可以组织冒泡，但不能阻止capture
			-->
			<div class="box1" @click="clickbox1">
				<div class="box2" @click.capture="clickbox2">
					<div class="box3" @click.stop="clickbox3">
						
					</div>
				</div>
			</div>
		</div>
		
		<!--
		self：
		-->
		<div id="test3">
			<p>{{ msg }}</p>
			<!--
				1、self只能由本身触发
				2、once只能触发一次，就算是从其他元素冒泡过来也不会被多次触发
				3、使用prevent串联once只能阻止一次默认事件，顺序交换结果不变once.prevent
			-->
			<div class="box1" @click.once="clickbox1">
				<div class="box2" @click.self="clickbox2">
					<div class="box3" @click.stop="clickbox3">
						
					</div>
				</div>
			</div>
			<a href="http://www.baidu.com" @click.prevent.once="clickhref">百度一下</a>
		</div>
	
		<!--ul#test>li.liclass{$}*5-->

		<!--table>((thead>th*5)+(tbody>td*5))*1-->
		<script>
			var vue = new Vue({
				el:'#test3',
				data:{
					msg:'testhshshs',
					btn:'点我点我快点我！',
					num:1
				},
				methods:{
					clickbox1(){
						console.log('点击box1')
					},
					clickbox2(){
						console.log('点击box2')
					},
					clickbox3(){
						console.log('点击box3')
					}
				}
			});
			var prevent = new Vue({
				el: '#test1',
				data: {
					msg: '哈哈哈哈'
				},
				methods: {
					clickhref(){
						console.log('点了点了')
					}
				}
			})
		</script>
	</body>
</html>
